package leetcode.code1702;

import leetcode.IDebug;

public class Solution implements IDebug {

	public String maximumBinaryString(String binary) {
		char[] cs = binary.toCharArray();
		int len = cs.length;
		for (int i = 0, p = 0; i < len; i++) {
			if (cs[i] == '0') {
				if (cs[p] == '1') {
					p = i;
				} else if (p != i) {
					cs[p++] = '1';
					cs[i] = '1';
					if (p < len)
						cs[p] = '0';
				}
			}
		}
		return new String(cs);
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
